import request from '@/utils/request'

/**
 * 获取报修区域列表（报修管理）
 * @return Promise
 */
export const screenAreaListAPI = () => {
  return request({
    url: '/common/area'
  })
}

/**
 * 获取报修区域接口
 * @param {Object} data: {account, password}
 * @return Promise
 */
export const getAreaInfoAPI = (id) => {
  return request({
    url: `/common/area/${id}`
  })
}

/**
 * 获取报修区域列表
 * @param {Object} data: { page: 页码, pagesize: 每页条数 }
 * @return Promise
 */
export const getAreaListAPI = (params) => {
  return request({
    url: '/area/',
    params
  })
}

/**
 * 根据name模糊查询报修区域
 * @param {Object} data: { page: 页码, pagesize: 每页条数, name:类型名称 }
 * @return Promise
 */
export const queryAreaAPI = (params) => {
  return request({
    url: '/area/query',
    params
  })
}

/**
 * 添加报修区域
 * @param {Object} data: { name: 名称, description: 描述 }
 * @return Promise
 */
export const addAreaAPI = (data) => {
  return request({
    url: '/area/',
    method: 'POST',
    data
  })
}

/**
 * 修改报修区域信息
 * @param {Object} data: { name: 名称, description: 描述 }
 * @return Promise
 */
export const updateAreaAPI = (data) => {
  return request({
    url: '/area/',
    method: 'PATCH',
    data
  })
}

/**
 * 删除报修区域
 * @param id
 * @return Promise
 */
export const deleteAreaAPI = (id) => {
  return request({
    url: `/area/${id}`,
    method: 'DELETE'
  })
}
